<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Rulebooks</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
function togglePopup(material_id) {
  var popup = document.getElementById(material_id);
  popup.classList.toggle("show");
}
</script>

<link href="../docs-assets/Popups.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
MathJax = {
	tex: {
		inlineMath: '$', '$'], ['\\(', '\\)'
	},
	svg: {
		fontCache: 'global'
	}
};
</script>
<script type="text/javascript" id="MathJax-script" async
	src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js">
</script>

<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Rulebooks' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../inform7n.html">Inform7</a></li><li><a href="index.html">assertions</a></li><li><a href="index.html#6">Chapter 6: Rules, Rulebooks and Activities</a></li><li><b>Rulebooks</b></li></ul></div>
<p class="purpose">Rulebooks collate rules and provide an organised way for them to collaborate on a larger task.</p>

<ul class="toc"><li><a href="6-rlb.html#SP1">&#167;1. Introduction</a></li><li><a href="6-rlb.html#SP12">&#167;12. Access</a></li><li><a href="6-rlb.html#SP14">&#167;14. Logging</a></li><li><a href="6-rlb.html#SP15">&#167;15. Rulebook variables</a></li><li><a href="6-rlb.html#SP17">&#167;17. Attaching and detaching rules</a></li><li><a href="6-rlb.html#SP19">&#167;19. Rule stems</a></li><li><a href="6-rlb.html#SP23">&#167;23. Notable rulebooks</a></li></ul><hr class="tocbar">

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. Introduction.</b>We think of a rulebook as being a list of rules, for which see the code in
<a href="6-bl.html" class="internal">Booking Lists</a>, but it also has a good deal of metadata. Handling that
metadata, and managing the creation of rulebooks, are the tasks here.
</p>

<p class="commentary">The semantics of rulebooks grew from their original mid-00s design of being
simple action-focused sets of game rules (for interactive fiction) to a point
in 2009 where they could essentially perform anything which a function in a
functional programming language such as Haskell could do. Their original
game-based purpose nevertheless still shows through in places, as with the
quaint idea of having enumerated ways in which they finish (see <a href="6-fao.html#SP2" class="internal">outcomes</a>).
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">primary_name</span><span class="plain-syntax">; </span><span class="comment-syntax"> name in source text</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">alternative_name</span><span class="plain-syntax">; </span><span class="comment-syntax"> alternative form of name</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">action_stem_length</span><span class="plain-syntax">; </span><span class="comment-syntax"> to do with parsing, but 0 for most rulebooks</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">booking_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">contents</span><span class="plain-syntax">; </span><span class="comment-syntax"> the actual rules in the rulebook</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">focus</span><span class="plain-syntax"> </span><span class="identifier-syntax">my_focus</span><span class="plain-syntax">; </span><span class="comment-syntax"> what does the rulebook work on?</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">outcomes</span><span class="plain-syntax"> </span><span class="identifier-syntax">my_outcomes</span><span class="plain-syntax">; </span><span class="comment-syntax"> how can it end?</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">rules_always_test_actor</span><span class="plain-syntax">; </span><span class="comment-syntax"> for action-tied check, carry out, report</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">automatically_generated</span><span class="plain-syntax">; </span><span class="comment-syntax"> rather than by explicit Inform 7 source text</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">runs_during_activities</span><span class="plain-syntax">; </span><span class="comment-syntax"> allow "while..." clauses to name these</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">shared_variable_set</span><span class="plain-syntax"> *</span><span class="identifier-syntax">my_variables</span><span class="plain-syntax">; </span><span class="comment-syntax"> rulebook variables owned here</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">shared_variable_access_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">accessible_variables</span><span class="plain-syntax">; </span><span class="comment-syntax"> and which can be named here</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">rulebook_compilation_data</span><span class="plain-syntax"> </span><span class="identifier-syntax">compilation_data</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">CLASS_DEFINITION</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">rulebook</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>The structure rulebook is accessed in 3/nuor, 3/rpr, 5/id, 5/idf, 5/adf, 5/tpf, 5/rf, 5/rcd, 6/rls, 6/fao, 6/act, 7/tc, 7/tbl, 7/eqt and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. </b>The following creates one:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="function-syntax">Rulebooks::new</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">Rulebooks::new</span></span>:<br/><a href="6-rlb.html#SP10">&#167;10</a><br/>The Creator - <a href="4-tc.html#SP4_3_2_4">&#167;4.3.2.4</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">create_as</span><span class="plain-syntax">, </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">package_request</span><span class="plain-syntax"> *</span><span class="identifier-syntax">R</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">rulebook</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="function-syntax">&lt;new-rulebook-name&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">primary_name</span><span class="plain-syntax"> = </span><span class="identifier-syntax">GET_RW</span><span class="plain-syntax">(</span><span class="function-syntax">&lt;new-rulebook-name&gt;</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">alternative_name</span><span class="plain-syntax"> = </span><span class="identifier-syntax">EMPTY_WORDING</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">action_stem_length</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><a href="6-rlb.html#SP25" class="function-link"><span class="function-syntax">Rulebooks::detect_notable</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">contents</span><span class="plain-syntax"> = </span><a href="6-bl.html#SP4" class="function-link"><span class="function-syntax">BookingLists::new</span></a><span class="plain-syntax">();</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">rules_always_test_actor</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">automatically_generated</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">runs_during_activities</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="6-rlb.html#SP2_1" class="named-paragraph-link"><span class="named-paragraph">Work out the focus and outcome</span><span class="named-paragraph-number">2.1</span></a></span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">compilation_data</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RTRulebooks::new_compilation_data</span><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">, </span><span class="identifier-syntax">R</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">my_variables</span><span class="plain-syntax"> = </span><a href="6-sv.html#SP6" class="function-link"><span class="function-syntax">SharedVariables::new_set</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">RTRulebooks::id_iname</span><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">accessible_variables</span><span class="plain-syntax"> = </span><a href="6-sv.html#SP8" class="function-link"><span class="function-syntax">SharedVariables::new_access_list</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><a href="6-sv.html#SP9" class="function-link"><span class="function-syntax">SharedVariables::add_set_to_access_list</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">accessible_variables</span><span class="plain-syntax">, </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">my_variables</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="6-rlb.html#SP2_2" class="named-paragraph-link"><span class="named-paragraph">Make proper nouns so that the rulebook can be a constant value</span><span class="named-paragraph-number">2.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">B</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. </b>We must check the supplied (primary) name for sanity:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;new-rulebook-name&gt;</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;definite-article&gt;</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;new-rulebook-name&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;new-rulebook-name&gt;</span><span class="plain-syntax"> </span><span class="identifier-syntax">rules</span><span class="plain-syntax">/</span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">at</span><span class="plain-syntax"> *** |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">to</span><span class="plain-syntax"> *** |</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">definition</span><span class="plain-syntax"> *** |</span>
<span class="plain-syntax">    ...</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3_1" class="paragraph-anchor"></a><b>&#167;3.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue PM_RulebookWithAt problem</span><span class="named-paragraph-number">3.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_RulebookWithAt</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="string-syntax">"this would create a rulebook whose name begins with 'at'"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"which is forbidden since it would lead to ambiguities in the way people write "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"rules. A rule beginning with 'At' is one which happens at a given time, whereas "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"a rule belonging to a rulebook starts with the name of that rulebook, so a "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"rulebook named 'at ...' would make such a rule inscrutable."</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="6-rlb.html#SP3">&#167;3</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP3_2" class="paragraph-anchor"></a><b>&#167;3.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue PM_RulebookWithTo problem</span><span class="named-paragraph-number">3.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_RulebookWithTo</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="string-syntax">"this would create a rulebook whose name begins with 'to'"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"which is forbidden since it would lead to ambiguities in the way people write "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"rules. A rule beginning with 'To' is one which defines a phrase, whereas a rule "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"belonging to a rulebook starts with the name of that rulebook, so a rulebook "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"named 'to ...' would make such a rule inscrutable."</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="6-rlb.html#SP3">&#167;3</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP3_3" class="paragraph-anchor"></a><b>&#167;3.3. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue PM_RulebookWithDefinition problem</span><span class="named-paragraph-number">3.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_RulebookWithDefinition</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="string-syntax">"this would create a rulebook whose name begins with 'definition'"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"which is forbidden since it would lead to ambiguities in the way people write "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"rules. A rule beginning with 'Definition' is one which defines an adjective, "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"whereas a rule belonging to a rulebook starts with the name of that rulebook, so "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"a rulebook named 'to ...' would make such a rule inscrutable."</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="6-rlb.html#SP3">&#167;3</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP2_1" class="paragraph-anchor"></a><b>&#167;2.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Work out the focus and outcome</span><span class="named-paragraph-number">2.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">parameter_kind</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">producing_kind</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Kinds::binary_construction_material</span><span class="plain-syntax">(</span><span class="identifier-syntax">create_as</span><span class="plain-syntax">, &amp;</span><span class="identifier-syntax">parameter_kind</span><span class="plain-syntax">, &amp;</span><span class="identifier-syntax">producing_kind</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::Behaviour::definite</span><span class="plain-syntax">(</span><span class="identifier-syntax">parameter_kind</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_RulebookIndefinite</span><span class="plain-syntax">),</span>
<span class="plain-syntax">            </span><span class="string-syntax">"this is a rulebook for values of a kind which isn't definite"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"and doesn't tell me enough about what sort of value the rulebook should "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"work on. For example, 'The mystery rules are a number based rulebook' is "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"fine because 'number' is definite, but 'The mystery rules are a value based "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"rulebook' is too vague."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">parameter_kind</span><span class="plain-syntax"> = </span><span class="identifier-syntax">K_object</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>

<span class="plain-syntax">    </span><a href="6-fao.html#SP1" class="function-link"><span class="function-syntax">FocusAndOutcome::initialise_focus</span></a><span class="plain-syntax">(&amp;(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">my_focus</span><span class="plain-syntax">), </span><span class="identifier-syntax">parameter_kind</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">def</span><span class="plain-syntax"> = </span><span class="constant-syntax">NO_OUTCOME</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">B</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RB_instead</span><span class="plain-syntax">) </span><span class="identifier-syntax">def</span><span class="plain-syntax"> = </span><span class="constant-syntax">FAILURE_OUTCOME</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">B</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RB_after</span><span class="plain-syntax">) </span><span class="identifier-syntax">def</span><span class="plain-syntax"> = </span><span class="constant-syntax">SUCCESS_OUTCOME</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">B</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RB_unsuccessful_attempt</span><span class="plain-syntax">) </span><span class="identifier-syntax">def</span><span class="plain-syntax"> = </span><span class="constant-syntax">SUCCESS_OUTCOME</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><a href="6-fao.html#SP7" class="function-link"><span class="function-syntax">FocusAndOutcome::initialise_outcomes</span></a><span class="plain-syntax">(&amp;(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">my_outcomes</span><span class="plain-syntax">), </span><span class="identifier-syntax">producing_kind</span><span class="plain-syntax">, </span><span class="identifier-syntax">def</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="6-rlb.html#SP2">&#167;2</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. </b>Focus and outcome are roughly the \(X\) and \(Y\) if we think of a rulebook as
being analogous to a function \(X\to Y\).
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Rulebooks::action_focus</span><button class="popup" onclick="togglePopup('usagePopup2')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup2">Usage of <span class="code-font"><span class="function-syntax">Rulebooks::action_focus</span></span>:<br/><a href="6-rlb.html#SP13">&#167;13</a><br/>Rule Family - <a href="5-rf.html#SP7_3">&#167;7.3</a>, <a href="5-rf.html#SP11_1">&#167;11.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">B</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="6-fao.html#SP1" class="function-link"><span class="function-syntax">FocusAndOutcome::action_focus</span></a><span class="plain-syntax">(&amp;(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">my_focus</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="function-syntax">Rulebooks::get_focus_kind</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">Rulebooks::get_focus_kind</span></span>:<br/><a href="6-rlb.html#SP6">&#167;6</a><br/>Rule Family - <a href="5-rf.html#SP11_1">&#167;11.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="6-fao.html#SP1" class="function-link"><span class="function-syntax">FocusAndOutcome::get_focus_parameter_kind</span></a><span class="plain-syntax">(&amp;(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">my_focus</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Rulebooks::base_on_nothing</span><span class="plain-syntax">(</span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="6-fao.html#SP1" class="function-link"><span class="function-syntax">FocusAndOutcome::focus_on_nothing</span></a><span class="plain-syntax">(&amp;(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">my_focus</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>

<span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="function-syntax">Rulebooks::get_outcome_kind</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">Rulebooks::get_outcome_kind</span></span>:<br/><a href="6-rlb.html#SP5">&#167;5</a>, <a href="6-rlb.html#SP6">&#167;6</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="6-fao.html#SP7" class="function-link"><span class="function-syntax">FocusAndOutcome::get_outcome_kind</span></a><span class="plain-syntax">(&amp;(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">my_outcomes</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">outcomes</span><span class="plain-syntax"> *</span><span class="function-syntax">Rulebooks::get_outcomes</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">Rulebooks::get_outcomes</span></span>:<br/>Focus and Outcome - <a href="6-fao.html#SP5">&#167;5</a>, <a href="6-fao.html#SP6">&#167;6</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> &amp;(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">my_outcomes</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. </b>During the period when a phrase from a rule in a rulebook is being compiled,
this rather clumsily finds out its return kind. Ideally we would get rid of
the need for this.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="function-syntax">Rulebooks::kind_from_context</span><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">id_body</span><span class="plain-syntax"> *</span><span class="identifier-syntax">idb</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Functions::defn_being_compiled</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">idb</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOOP_OVER</span><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">, </span><span class="reserved-syntax">rulebook</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="6-bl.html#SP7" class="function-link"><span class="function-syntax">BookingLists::contains_ph</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">contents</span><span class="plain-syntax">, </span><span class="identifier-syntax">idb</span><span class="plain-syntax">))</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="6-rlb.html#SP4" class="function-link"><span class="function-syntax">Rulebooks::get_outcome_kind</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. </b>While focus and outcome are each more involved than just being a kind of
value, we reduce them to that when working out the kind of a rulebook and
of the rules in it:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="function-syntax">Rulebooks::to_kind</span><span class="plain-syntax">(</span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">Kinds::binary_con</span><span class="plain-syntax">(</span><span class="identifier-syntax">CON_rulebook</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><a href="6-rlb.html#SP4" class="function-link"><span class="function-syntax">Rulebooks::get_focus_kind</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">), </span><a href="6-rlb.html#SP4" class="function-link"><span class="function-syntax">Rulebooks::get_outcome_kind</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>

<span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="function-syntax">Rulebooks::contains_kind</span><button class="popup" onclick="togglePopup('usagePopup6')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup6">Usage of <span class="code-font"><span class="function-syntax">Rulebooks::contains_kind</span></span>:<br/>Rules - <a href="6-rls.html#SP7">&#167;7</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">Kinds::binary_con</span><span class="plain-syntax">(</span><span class="identifier-syntax">CON_rule</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><a href="6-rlb.html#SP4" class="function-link"><span class="function-syntax">Rulebooks::get_focus_kind</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">), </span><a href="6-rlb.html#SP4" class="function-link"><span class="function-syntax">Rulebooks::get_outcome_kind</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. </b>Unsurprisingly, the (primary) name for a rulebook becomes a noun which can be
referred to in Inform 7 source text. In fact two alternative forms of this noun
are also created, which are both synonyms for it. Thus if a "coordination"
rulebook is created, it can be referred to as any of "coordination", "coordination rules"
or "coordination rulebook":
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;rulebook-name-construction&gt;</span>
<span class="plain-syntax">    ... </span><span class="identifier-syntax">rules</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    ... </span><span class="reserved-syntax">rulebook</span>
</pre>
<p class="commentary firstcommentary"><a id="SP2_2" class="paragraph-anchor"></a><b>&#167;2.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Make proper nouns so that the rulebook can be a constant value</span><span class="named-paragraph-number">2.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">Nouns::new_proper_noun</span><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">primary_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">NEUTER_GENDER</span><span class="plain-syntax">, </span><span class="identifier-syntax">ADD_TO_LEXICON_NTOPT</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RULEBOOK_MC</span><span class="plain-syntax">, </span><span class="identifier-syntax">Rvalues::from_rulebook</span><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">), </span><span class="identifier-syntax">Task::language_of_syntax</span><span class="plain-syntax">());</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">word_assemblage</span><span class="plain-syntax"> </span><span class="identifier-syntax">wa</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">PreformUtilities::merge</span><span class="plain-syntax">(</span><span class="function-syntax">&lt;rulebook-name-construction&gt;</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WordAssemblages::from_wording</span><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">primary_name</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">AW</span><span class="plain-syntax"> = </span><span class="identifier-syntax">WordAssemblages::to_wording</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">wa</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Nouns::new_proper_noun</span><span class="plain-syntax">(</span><span class="identifier-syntax">AW</span><span class="plain-syntax">, </span><span class="identifier-syntax">NEUTER_GENDER</span><span class="plain-syntax">, </span><span class="identifier-syntax">ADD_TO_LEXICON_NTOPT</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RULEBOOK_MC</span><span class="plain-syntax">, </span><span class="identifier-syntax">Rvalues::from_rulebook</span><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">), </span><span class="identifier-syntax">Task::language_of_syntax</span><span class="plain-syntax">());</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">wa</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PreformUtilities::merge</span><span class="plain-syntax">(</span><span class="function-syntax">&lt;rulebook-name-construction&gt;</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WordAssemblages::from_wording</span><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">primary_name</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">AW</span><span class="plain-syntax"> = </span><span class="identifier-syntax">WordAssemblages::to_wording</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">wa</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Nouns::new_proper_noun</span><span class="plain-syntax">(</span><span class="identifier-syntax">AW</span><span class="plain-syntax">, </span><span class="identifier-syntax">NEUTER_GENDER</span><span class="plain-syntax">, </span><span class="identifier-syntax">ADD_TO_LEXICON_NTOPT</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RULEBOOK_MC</span><span class="plain-syntax">, </span><span class="identifier-syntax">Rvalues::from_rulebook</span><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">), </span><span class="identifier-syntax">Task::language_of_syntax</span><span class="plain-syntax">());</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="6-rlb.html#SP2">&#167;2</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. </b>It can also subsequently be given a further or "alternative" name, and that
too becomes a proper noun, but is not run through &lt;rulebook-name-construction&gt;
to make still further variants. So the rulebook has at most four different
names, one more than cats have.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Rulebooks::set_alt_name</span><span class="plain-syntax">(</span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">, </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">AW</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">alternative_name</span><span class="plain-syntax"> = </span><span class="identifier-syntax">AW</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Nouns::new_proper_noun</span><span class="plain-syntax">(</span><span class="identifier-syntax">AW</span><span class="plain-syntax">, </span><span class="identifier-syntax">NEUTER_GENDER</span><span class="plain-syntax">, </span><span class="identifier-syntax">ADD_TO_LEXICON_NTOPT</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RULEBOOK_MC</span><span class="plain-syntax">, </span><span class="identifier-syntax">Rvalues::from_rulebook</span><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">), </span><span class="identifier-syntax">Task::language_of_syntax</span><span class="plain-syntax">());</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP9" class="paragraph-anchor"></a><b>&#167;9. </b>And these up to four nouns can be matched with the following nonterminal.
</p>

<p class="commentary">The process of noticing rulebook names inside parts of rule names is much
more complex &mdash; see <a href="6-rlb.html#SP22" class="internal">Rulebooks::rb_match_from_description</a> below.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;rulebook-name&gt;</span><span class="plain-syntax"> </span><span class="identifier-syntax">internal</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">W</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Articles::remove_the</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">p</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Lexicon::retrieve</span><span class="plain-syntax">(</span><span class="identifier-syntax">RULEBOOK_MC</span><span class="plain-syntax">, </span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Rvalues::is_CONSTANT_construction</span><span class="plain-syntax">(</span><span class="identifier-syntax">p</span><span class="plain-syntax">, </span><span class="identifier-syntax">CON_rulebook</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        ==&gt; { -, </span><span class="identifier-syntax">Rvalues::to_rulebook</span><span class="plain-syntax">(</span><span class="identifier-syntax">p</span><span class="plain-syntax">) };</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    ==&gt; { </span><span class="identifier-syntax">fail</span><span class="plain-syntax"> </span><span class="identifier-syntax">nonterminal</span><span class="plain-syntax"> };</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP10" class="paragraph-anchor"></a><b>&#167;10. </b>"Automatic" rulebooks sound fancy, but there's very little going on here.
These are created as a knock-on effect of something else being created: for
example if the source text creates an action, then rulebooks for processing
that action are automatically created, and similarly for activities and scenes.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="function-syntax">Rulebooks::new_automatic</span><button class="popup" onclick="togglePopup('usagePopup7')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup7">Usage of <span class="code-font"><span class="function-syntax">Rulebooks::new_automatic</span></span>:<br/>Activities - <a href="6-act.html#SP7">&#167;7</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">basis</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">default_outcome</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">always_test_actor</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">for_activities</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">stem_length</span><span class="plain-syntax">, </span><span class="identifier-syntax">package_request</span><span class="plain-syntax"> *</span><span class="identifier-syntax">R</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax"> = </span><a href="6-rlb.html#SP2" class="function-link"><span class="function-syntax">Rulebooks::new</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">Kinds::binary_con</span><span class="plain-syntax">(</span><span class="identifier-syntax">CON_rulebook</span><span class="plain-syntax">, </span><span class="identifier-syntax">basis</span><span class="plain-syntax">, </span><span class="identifier-syntax">K_void</span><span class="plain-syntax">), </span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">R</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="6-fao.html#SP7" class="function-link"><span class="function-syntax">FocusAndOutcome::set_default_outcome</span></a><span class="plain-syntax">(&amp;(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">my_outcomes</span><span class="plain-syntax">), </span><span class="identifier-syntax">default_outcome</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">rules_always_test_actor</span><span class="plain-syntax"> = </span><span class="identifier-syntax">always_test_actor</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">automatically_generated</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">runs_during_activities</span><span class="plain-syntax"> = </span><span class="identifier-syntax">for_activities</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">action_stem_length</span><span class="plain-syntax"> = </span><span class="identifier-syntax">stem_length</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">B</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP11" class="paragraph-anchor"></a><b>&#167;11. </b>The author can demand with a "translates as" sentence that a given
rulebook should have an identifier given to it which is accessible to Inter:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Rulebooks::translates</span><button class="popup" onclick="togglePopup('usagePopup8')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup8">Usage of <span class="code-font"><span class="function-syntax">Rulebooks::translates</span></span>:<br/>Translation Requests - <a href="3-tr.html#SP9_1_2">&#167;9.1.2</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">p2</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="function-syntax">&lt;rulebook-name&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax"> = (</span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *) </span><span class="function-syntax">&lt;&lt;rp&gt;&gt;</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RTRulebooks::translate</span><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">, </span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">p2</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"Tried %W\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_TranslatesNonRulebook</span><span class="plain-syntax">),</span>
<span class="plain-syntax">            </span><span class="string-syntax">"this is not the name of a rulebook"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"so cannot be translated."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP12" class="paragraph-anchor"></a><b>&#167;12. Access.</b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Rulebooks::requires_specific_action</span><span class="plain-syntax">(</span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">B</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RB_check</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">B</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RB_carry_out</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">B</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RB_report</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">action_stem_length</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Rulebooks::is_empty</span><span class="plain-syntax">(</span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">B</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="6-bl.html#SP7" class="function-link"><span class="function-syntax">BookingLists::is_empty_of_i7_rules</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">contents</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Rulebooks::no_rules</span><span class="plain-syntax">(</span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">B</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="6-bl.html#SP7" class="function-link"><span class="function-syntax">BookingLists::length</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">contents</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Rulebooks::rule_in_rulebook</span><button class="popup" onclick="togglePopup('usagePopup9')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup9">Usage of <span class="code-font"><span class="function-syntax">Rulebooks::rule_in_rulebook</span></span>:<br/>Rule Placement Requests - <a href="3-rpr.html#SP15_1">&#167;15.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">rule</span><span class="plain-syntax"> *</span><span class="identifier-syntax">R</span><span class="plain-syntax">, </span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">B</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="6-bl.html#SP7" class="function-link"><span class="function-syntax">BookingLists::contains</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">contents</span><span class="plain-syntax">, </span><span class="identifier-syntax">R</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">booking</span><span class="plain-syntax"> *</span><span class="function-syntax">Rulebooks::first_booking</span><span class="plain-syntax">(</span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">B</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="6-bl.html#SP7" class="function-link"><span class="function-syntax">BookingLists::first</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">contents</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Rulebooks::runs_during_activities</span><button class="popup" onclick="togglePopup('usagePopup10')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup10">Usage of <span class="code-font"><span class="function-syntax">Rulebooks::runs_during_activities</span></span>:<br/>Rule Family - <a href="5-rf.html#SP7_3">&#167;7.3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">runs_during_activities</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP13" class="paragraph-anchor"></a><b>&#167;13. </b><span class="extract"><span class="extract-syntax">rules_always_test_actor</span></span> is set (and meaningful) only for action focuses.
It marks a rulebook as definitely needing to check the actor.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Rulebooks::modify_rule_to_suit_focus</span><span class="plain-syntax">(</span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">, </span><span class="reserved-syntax">rule</span><span class="plain-syntax"> *</span><span class="identifier-syntax">R</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="6-rlb.html#SP4" class="function-link"><span class="function-syntax">Rulebooks::action_focus</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">rules_always_test_actor</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">RULE_ATTACHMENTS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="string-syntax">"Setting always test actor for destination rulebook\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><a href="6-rls.html#SP18" class="function-link"><span class="function-syntax">Rules::set_always_test_actor</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">R</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">RULE_ATTACHMENTS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"Setting never test actor for destination rulebook\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="6-rls.html#SP18" class="function-link"><span class="function-syntax">Rules::set_never_test_actor</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">R</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP14" class="paragraph-anchor"></a><b>&#167;14. Logging.</b>Just to name it, or giving an inventory of the contents.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Rulebooks::log_name_only</span><span class="plain-syntax">(</span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"Rulebook %d (%W)"</span><span class="plain-syntax">, </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">allocation_id</span><span class="plain-syntax">, </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">primary_name</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Rulebooks::log</span><span class="plain-syntax">(</span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="6-rlb.html#SP14" class="function-link"><span class="function-syntax">Rulebooks::log_name_only</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">": "</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="6-bl.html#SP3" class="function-link"><span class="function-syntax">BookingLists::log</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">contents</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP15" class="paragraph-anchor"></a><b>&#167;15. Rulebook variables.</b>This function is called in response to a sentence like "The consideration rulebook
has a D called W":
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">shared_variable_set</span><span class="plain-syntax"> *</span><span class="function-syntax">Rulebooks::variables</span><button class="popup" onclick="togglePopup('usagePopup11')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup11">Usage of <span class="code-font"><span class="function-syntax">Rulebooks::variables</span></span>:<br/>Rules - <a href="6-rls.html#SP10">&#167;10</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">my_variables</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">shared_variable_access_list</span><span class="plain-syntax"> *</span><span class="function-syntax">Rulebooks::accessible_variables</span><button class="popup" onclick="togglePopup('usagePopup12')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup12">Usage of <span class="code-font"><span class="function-syntax">Rulebooks::accessible_variables</span></span>:<br/><a href="6-rlb.html#SP16">&#167;16</a>, <a href="6-rlb.html#SP17">&#167;17</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">accessible_variables</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Rulebooks::add_variable</span><button class="popup" onclick="togglePopup('usagePopup13')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup13">Usage of <span class="code-font"><span class="function-syntax">Rulebooks::add_variable</span></span>:<br/>Assertions - <a href="4-ass.html#SP6_3_25_2">&#167;6.3.25.2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">, </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cnode</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="6-rlb.html#SP15_1" class="named-paragraph-link"><span class="named-paragraph">The variable has to have a name</span><span class="named-paragraph-number">15.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">D</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">cnode</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">cnode</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="6-rlb.html#SP15_2" class="named-paragraph-link"><span class="named-paragraph">The variable name must be fortunate</span><span class="named-paragraph-number">15.2</span></a></span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">spec</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="function-syntax">&lt;s-type-expression&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">D</span><span class="plain-syntax">)) </span><span class="identifier-syntax">spec</span><span class="plain-syntax"> = </span><span class="function-syntax">&lt;&lt;rp&gt;&gt;</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="6-rlb.html#SP15_3" class="named-paragraph-link"><span class="named-paragraph">Its description cannot be qualified</span><span class="named-paragraph-number">15.3</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="6-rlb.html#SP15_4" class="named-paragraph-link"><span class="named-paragraph">Its description cannot be a constant name</span><span class="named-paragraph-number">15.4</span></a></span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Specifications::to_kind</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="6-rlb.html#SP15_5" class="named-paragraph-link"><span class="named-paragraph">In fact, its description has to be a kind</span><span class="named-paragraph-number">15.5</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="6-rlb.html#SP15_6" class="named-paragraph-link"><span class="named-paragraph">And a definite one at that</span><span class="named-paragraph-number">15.6</span></a></span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">is_actor</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">shared_variable_set</span><span class="plain-syntax"> *</span><span class="identifier-syntax">vars</span><span class="plain-syntax"> = </span><a href="6-rlb.html#SP15" class="function-link"><span class="function-syntax">Rulebooks::variables</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">B</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RB_action_processing</span><span class="plain-syntax">) &amp;&amp;</span>
<span class="plain-syntax">        (</span><a href="6-sv.html#SP6" class="function-link"><span class="function-syntax">SharedVariables::set_empty</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">vars</span><span class="plain-syntax">)))</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">is_actor</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><a href="6-sv.html#SP3" class="function-link"><span class="function-syntax">SharedVariables::new</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">vars</span><span class="plain-syntax">, </span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="identifier-syntax">is_actor</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP15_1" class="paragraph-anchor"></a><b>&#167;15.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">The variable has to have a name</span><span class="named-paragraph-number">15.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Node::get_type</span><span class="plain-syntax">(</span><span class="identifier-syntax">cnode</span><span class="plain-syntax">) != </span><span class="identifier-syntax">PROPERTYCALLED_NT</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_source</span><span class="plain-syntax">(1, </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::handmade_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_RulebookVarUncalled</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span>
<span class="plain-syntax">            </span><span class="string-syntax">"You wrote %1, which I am reading as a request to make a new named variable "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"for an rulebook - a value associated with a action and which has a name. "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"But since you only give a kind, not a name, I'm stuck. ('The every turn "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"rulebook has a number called importance' is right, 'The every turn rulebook "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"has a number' is too vague.)"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_end</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="6-rlb.html#SP15">&#167;15</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP15_2" class="paragraph-anchor"></a><b>&#167;15.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">The variable name must be fortunate</span><span class="named-paragraph-number">15.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="function-syntax">&lt;unfortunate-name&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_source</span><span class="plain-syntax">(1, </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_wording</span><span class="plain-syntax">(2, </span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::handmade_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_RulebookVariableAnd</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span>
<span class="plain-syntax">            </span><span class="string-syntax">"You wrote %1, which I am reading as a request to make a new named variable "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"for a rulebook - a value associated with a rulebook and which has a name. "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"The request seems to say that the name in question is '%2', but I'd prefer to "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"avoid punctuation marks, 'and', 'or', 'with', or 'having' in such names, please."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_end</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="6-rlb.html#SP15">&#167;15</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP15_3" class="paragraph-anchor"></a><b>&#167;15.3. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Its description cannot be qualified</span><span class="named-paragraph-number">15.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Specifications::is_description</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">)) &amp;&amp;</span>
<span class="plain-syntax">        (</span><span class="identifier-syntax">Descriptions::is_qualified</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_source</span><span class="plain-syntax">(1, </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_wording</span><span class="plain-syntax">(2, </span><span class="identifier-syntax">D</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::handmade_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_RulebookVariableTooSpecific</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span>
<span class="plain-syntax">            </span><span class="string-syntax">"You wrote %1, which I am reading as a request to make a new named variable "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"for a rulebook - a value associated with a rulebook and which has a name. "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"The request seems to say that the value in question is '%2', but this is "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"too specific a description. (Instead, a kind of value (such as 'number') or "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"a kind of object (such as 'room' or 'thing') should be given. To get a "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"property whose contents can be any kind of object, use 'object'.)"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_end</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="6-rlb.html#SP15">&#167;15</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP15_4" class="paragraph-anchor"></a><b>&#167;15.4. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Its description cannot be a constant name</span><span class="named-paragraph-number">15.4</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Node::is</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">, </span><span class="identifier-syntax">CONSTANT_NT</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_source</span><span class="plain-syntax">(1, </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_wording</span><span class="plain-syntax">(2, </span><span class="identifier-syntax">D</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::handmade_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_RulebookVariableBadKind</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span>
<span class="plain-syntax">            </span><span class="string-syntax">"You wrote %1, but '%2' is not the name of a kind of value which I know "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"(such as 'number' or 'text')."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_end</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="6-rlb.html#SP15">&#167;15</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP15_5" class="paragraph-anchor"></a><b>&#167;15.5. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">In fact, its description has to be a kind</span><span class="named-paragraph-number">15.5</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">K</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_source</span><span class="plain-syntax">(1, </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_wording</span><span class="plain-syntax">(2, </span><span class="identifier-syntax">D</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::handmade_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_RulebookVariableKindless</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span>
<span class="plain-syntax">            </span><span class="string-syntax">"You wrote %1, but I was expecting to see a kind of value there, and '%2' "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"isn't something I recognise as a kind."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_end</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="6-rlb.html#SP15">&#167;15</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP15_6" class="paragraph-anchor"></a><b>&#167;15.6. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">And a definite one at that</span><span class="named-paragraph-number">15.6</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::Behaviour::definite</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_source</span><span class="plain-syntax">(1, </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_wording</span><span class="plain-syntax">(2, </span><span class="identifier-syntax">D</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::handmade_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_RulebookVariableVague</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span>
<span class="plain-syntax">            </span><span class="string-syntax">"You wrote %1, but saying that a variable is something as vague as this does "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"not give me a clear enough idea what it will hold. You need to say what kind "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"of value: for instance, 'A door has a number called street address.' is "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"allowed because 'number' is specific about the kind of value."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_end</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="6-rlb.html#SP15">&#167;15</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP16" class="paragraph-anchor"></a><b>&#167;16. </b>Rulebooks can also be given access to other sets of variables which are
defined somewhere else &mdash; but they still don't belong to <span class="extract"><span class="extract-syntax">B</span></span>, so they do not
go into <span class="extract"><span class="extract-syntax">B-&gt;my_variables</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Rulebooks::grant_access_to_variables</span><button class="popup" onclick="togglePopup('usagePopup14')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup14">Usage of <span class="code-font"><span class="function-syntax">Rulebooks::grant_access_to_variables</span></span>:<br/>Activities - <a href="6-act.html#SP7">&#167;7</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">, </span><span class="reserved-syntax">shared_variable_set</span><span class="plain-syntax"> *</span><span class="identifier-syntax">set</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="6-sv.html#SP9" class="function-link"><span class="function-syntax">SharedVariables::add_set_to_access_list</span></a><span class="plain-syntax">(</span><a href="6-rlb.html#SP15" class="function-link"><span class="function-syntax">Rulebooks::accessible_variables</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">), </span><span class="identifier-syntax">set</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP17" class="paragraph-anchor"></a><b>&#167;17. Attaching and detaching rules.</b>The following routine contains a bit of a surprise: that the act of
placing a BR within a given rulebook can change it, by altering the way
it acts on its applicability test. This is a device needed to manage
the parallel rulebooks for action processing for the main player character
and for third parties. Though the code below does not make this apparent,
the changes propagate down through the BR to the phrase structure itself.
This is necessary because they manifest themselves in the compiled code
of the phrase, but it is also unfortunate, because it is possible that
the same phrase is used by more than one BR. If it should happen that
BRs are created to place the same phrase into two different rulebooks,
therefore, and which have different actor-testing settings, the outcome
would be confusing. (As unlikely as this seems, it did once happen to a
user in beta-testing.)
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Rulebooks::attach_rule</span><button class="popup" onclick="togglePopup('usagePopup15')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup15">Usage of <span class="code-font"><span class="function-syntax">Rulebooks::attach_rule</span></span>:<br/>Rule Placement Requests - <a href="3-rpr.html#SP15_1">&#167;15.1</a><br/>Rule Bookings - <a href="6-rb.html#SP6">&#167;6</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">, </span><span class="reserved-syntax">booking</span><span class="plain-syntax"> *</span><span class="identifier-syntax">br</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">placing</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">side</span><span class="plain-syntax">, </span><span class="reserved-syntax">rule</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ref_rule</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">RULE_ATTACHMENTS</span><span class="plain-syntax">, </span><span class="string-syntax">"Attaching booking $b to rulebook $K"</span><span class="plain-syntax">, </span><span class="identifier-syntax">br</span><span class="plain-syntax">, </span><span class="identifier-syntax">B</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">rule</span><span class="plain-syntax"> *</span><span class="identifier-syntax">R</span><span class="plain-syntax"> = </span><a href="6-rb.html#SP4" class="function-link"><span class="function-syntax">RuleBookings::get_rule</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">br</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">R</span><span class="plain-syntax"> == </span><span class="identifier-syntax">ref_rule</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">side</span><span class="plain-syntax"> != </span><span class="constant-syntax">INSTEAD_SIDE</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_BeforeOrAfterSelf</span><span class="plain-syntax">),</span>
<span class="plain-syntax">            </span><span class="string-syntax">"a rule can't be before or after itself"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"so this makes no sense to me."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">placing</span><span class="plain-syntax"> == </span><span class="constant-syntax">VERY_FIRST_PLACEMENT</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">placing</span><span class="plain-syntax"> == </span><span class="constant-syntax">VERY_LAST_PLACEMENT</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">inform_extension</span><span class="plain-syntax"> *</span><span class="identifier-syntax">BX</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Extensions::containing</span><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">compilation_data</span><span class="plain-syntax">.</span><span class="element-syntax">where_declared</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">inform_extension</span><span class="plain-syntax"> *</span><span class="identifier-syntax">RX</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Extensions::containing</span><span class="plain-syntax">(</span><span class="identifier-syntax">R</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">compilation_data</span><span class="plain-syntax">.</span><span class="element-syntax">where_declared</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">BX</span><span class="plain-syntax"> != </span><span class="identifier-syntax">RX</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_VeryRuleTooDistant</span><span class="plain-syntax">),</span>
<span class="plain-syntax">                </span><span class="string-syntax">"the 'very first' or 'very last' rule for a rulebook can only be "</span>
<span class="plain-syntax">                </span><span class="string-syntax">"created in the same extension as the rulebook itself"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="string-syntax">"or else in the main body of the source text if that's where the "</span>
<span class="plain-syntax">                </span><span class="string-syntax">"rulebook is defined."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">PluginCalls::rule_placement_notify</span><span class="plain-syntax">(</span><span class="identifier-syntax">R</span><span class="plain-syntax">, </span><span class="identifier-syntax">B</span><span class="plain-syntax">, </span><span class="identifier-syntax">side</span><span class="plain-syntax">, </span><span class="identifier-syntax">ref_rule</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><a href="6-rls.html#SP10" class="function-link"><span class="function-syntax">Rules::put_variables_in_scope</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">R</span><span class="plain-syntax">, </span><a href="6-rlb.html#SP15" class="function-link"><span class="function-syntax">Rulebooks::accessible_variables</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">side</span><span class="plain-syntax"> == </span><span class="constant-syntax">INSTEAD_SIDE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">RULE_ATTACHMENTS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"Copying former rulebook's variable permissions to displaced rule\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="6-rls.html#SP10" class="function-link"><span class="function-syntax">Rules::put_variables_in_scope</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ref_rule</span><span class="plain-syntax">, </span><a href="6-rlb.html#SP15" class="function-link"><span class="function-syntax">Rulebooks::accessible_variables</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    }</span>

<span class="plain-syntax">    </span><a href="5-rcd.html#SP6" class="function-link"><span class="function-syntax">RuntimeContextData::ensure_avl</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">R</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><a href="6-bl.html#SP5" class="function-link"><span class="function-syntax">BookingLists::add</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">contents</span><span class="plain-syntax">, </span><span class="identifier-syntax">br</span><span class="plain-syntax">, </span><span class="identifier-syntax">placing</span><span class="plain-syntax">, </span><span class="identifier-syntax">side</span><span class="plain-syntax">, </span><span class="identifier-syntax">ref_rule</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">RULE_ATTACHMENTS</span><span class="plain-syntax">, </span><span class="string-syntax">"Rulebook after attachment: $K"</span><span class="plain-syntax">, </span><span class="identifier-syntax">B</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP18" class="paragraph-anchor"></a><b>&#167;18. </b>This at least is easy:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Rulebooks::detach_rule</span><button class="popup" onclick="togglePopup('usagePopup16')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup16">Usage of <span class="code-font"><span class="function-syntax">Rulebooks::detach_rule</span></span>:<br/>Rule Placement Requests - <a href="3-rpr.html#SP15_1_3">&#167;15.1.3</a>, <a href="3-rpr.html#SP15_1_4">&#167;15.1.4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">, </span><span class="reserved-syntax">rule</span><span class="plain-syntax"> *</span><span class="identifier-syntax">R</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="6-bl.html#SP6" class="function-link"><span class="function-syntax">BookingLists::remove</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">contents</span><span class="plain-syntax">, </span><span class="identifier-syntax">R</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP19" class="paragraph-anchor"></a><b>&#167;19. Rule stems.</b>The voracious nonterminal &lt;rulebook-stem&gt; finds the "stem" of a rule, that is,
the part which identifies which rulebook it will go into. For example, in;
</p>

<blockquote>
    <p>Before printing the name of the peach: ...</p>
</blockquote>

<blockquote>
    <p>Instead of eating: ...</p>
</blockquote>

<p class="commentary">the stems are "before printing the name" and "instead".
</p>

<p class="commentary">The results are, however, too complicated to return from &lt;rulebook-stem&gt;; since
it is not used recursively, we store the results in <span class="extract"><span class="extract-syntax">parsed_rm</span></span> on success.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">rulebook_match</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">matched_rulebook</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">match_from</span><span class="plain-syntax">; </span><span class="comment-syntax"> first word of matched text</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">match_length</span><span class="plain-syntax">; </span><span class="comment-syntax"> number of words in matched text</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">advance_words</span><span class="plain-syntax">; </span><span class="comment-syntax"> how far the nonterminal should advance</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">tail_words</span><span class="plain-syntax">; </span><span class="comment-syntax"> for rulebook names split by scene start or end</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">article</span><span class="plain-syntax"> *</span><span class="identifier-syntax">article_used</span><span class="plain-syntax">; </span><span class="comment-syntax"> or </span><span class="extract"><span class="extract-syntax">NULL</span></span><span class="comment-syntax"> if none was</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">placement_requested</span><span class="plain-syntax">; </span><span class="comment-syntax"> one of the </span><span class="extract"><span class="extract-syntax">*_PLACEMENT</span></span><span class="comment-syntax"> values</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">rulebook_match</span><span class="plain-syntax">;</span>

<span class="reserved-syntax">rulebook_match</span><span class="plain-syntax"> </span><span class="identifier-syntax">parsed_rm</span><span class="plain-syntax">;</span>

<span class="reserved-syntax">rulebook_match</span><span class="plain-syntax"> *</span><span class="function-syntax">Rulebooks::match</span><button class="popup" onclick="togglePopup('usagePopup17')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup17">Usage of <span class="code-font"><span class="function-syntax">Rulebooks::match</span></span>:<br/>Rule Family - <a href="5-rf.html#SP7">&#167;7</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> &amp;</span><span class="identifier-syntax">parsed_rm</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">parsed_scene_stem_len</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">parsed_scene_stem_B</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>The structure rulebook_match is accessed in 5/rf and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP20" class="paragraph-anchor"></a><b>&#167;20. </b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;rulebook-stem&gt;</span><span class="plain-syntax"> </span><span class="identifier-syntax">internal</span><span class="plain-syntax"> ?</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">initial_w1</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">parsed_scene_stem_len</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">parsed_scene_stem_B</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="function-syntax">&lt;rulebook-stem-inner&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">W</span><span class="plain-syntax"> = </span><span class="identifier-syntax">GET_RW</span><span class="plain-syntax">(</span><span class="function-syntax">&lt;rulebook-stem-name&gt;</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">modifier_words</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">) - </span><span class="identifier-syntax">initial_w1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">article_usage</span><span class="plain-syntax"> *</span><span class="identifier-syntax">au</span><span class="plain-syntax"> = (</span><span class="identifier-syntax">article_usage</span><span class="plain-syntax"> *) </span><span class="function-syntax">&lt;&lt;rp&gt;&gt;</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">pl</span><span class="plain-syntax"> = </span><span class="function-syntax">&lt;&lt;r&gt;&gt;</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">rulebook_match</span><span class="plain-syntax"> </span><span class="identifier-syntax">rm</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">rm</span><span class="plain-syntax">.</span><span class="element-syntax">match_length</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">rm</span><span class="plain-syntax">.</span><span class="element-syntax">advance_words</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">rm</span><span class="plain-syntax">.</span><span class="element-syntax">tail_words</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">rm</span><span class="plain-syntax">.</span><span class="element-syntax">matched_rulebook</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="6-rlb.html#SP22" class="function-link"><span class="function-syntax">Rulebooks::rb_match_from_description</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">parsed_scene_stem_B</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">parsed_scene_stem_len</span><span class="plain-syntax">, &amp;</span><span class="identifier-syntax">rm</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">parsed_rm</span><span class="plain-syntax"> = </span><span class="identifier-syntax">rm</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">parsed_rm</span><span class="plain-syntax">.</span><span class="element-syntax">match_length</span><span class="plain-syntax"> += </span><span class="identifier-syntax">modifier_words</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">parsed_rm</span><span class="plain-syntax">.</span><span class="element-syntax">advance_words</span><span class="plain-syntax"> += </span><span class="identifier-syntax">modifier_words</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">parsed_rm</span><span class="plain-syntax">.</span><span class="element-syntax">match_from</span><span class="plain-syntax"> = </span><span class="identifier-syntax">initial_w1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">parsed_rm</span><span class="plain-syntax">.</span><span class="element-syntax">article_used</span><span class="plain-syntax"> = (</span><span class="identifier-syntax">au</span><span class="plain-syntax">)?(</span><span class="identifier-syntax">au</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">article_used</span><span class="plain-syntax">):</span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">parsed_rm</span><span class="plain-syntax">.</span><span class="element-syntax">placement_requested</span><span class="plain-syntax"> = </span><span class="identifier-syntax">pl</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">initial_w1</span><span class="plain-syntax"> + </span><span class="identifier-syntax">parsed_rm</span><span class="plain-syntax">.</span><span class="element-syntax">advance_words</span><span class="plain-syntax"> - </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    ==&gt; { </span><span class="identifier-syntax">fail</span><span class="plain-syntax"> </span><span class="identifier-syntax">nonterminal</span><span class="plain-syntax"> };</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP21" class="paragraph-anchor"></a><b>&#167;21. </b>Suppose this is our rule:
</p>

<blockquote>
    <p>The first rule for printing the name of something: ...</p>
</blockquote>

<p class="commentary">the following grammar peels away the easier-to-read indications at the front. It
notes the use of "The", and the placement "first"; it throws away other verbiage so
that &lt;rulebook-stem-name&gt; matches "printing the name of something".
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;rulebook-stem-inner&gt;</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;indefinite-article&gt;</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;rulebook-stem-inner-unarticled&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;definite-article&gt;</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;rulebook-stem-inner-unarticled&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;rulebook-stem-inner-unarticled&gt;</span>

<span class="function-syntax">&lt;rulebook-stem-inner-unarticled&gt;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rule</span><span class="plain-syntax"> </span><span class="reserved-syntax">for</span><span class="plain-syntax">/</span><span class="identifier-syntax">about</span><span class="plain-syntax">/</span><span class="identifier-syntax">on</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;rulebook-stem-name&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rule</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;rulebook-stem-name&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">very</span><span class="plain-syntax"> </span><span class="identifier-syntax">first</span><span class="plain-syntax"> </span><span class="reserved-syntax">rule</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;rulebook-stem-name&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">very</span><span class="plain-syntax"> </span><span class="identifier-syntax">first</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;rulebook-stem-name&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">first</span><span class="plain-syntax"> </span><span class="reserved-syntax">rule</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;rulebook-stem-name&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">first</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;rulebook-stem-name&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">last</span><span class="plain-syntax"> </span><span class="reserved-syntax">rule</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;rulebook-stem-name&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">last</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;rulebook-stem-name&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">very</span><span class="plain-syntax"> </span><span class="identifier-syntax">last</span><span class="plain-syntax"> </span><span class="reserved-syntax">rule</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;rulebook-stem-name&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">very</span><span class="plain-syntax"> </span><span class="identifier-syntax">last</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;rulebook-stem-name&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;rulebook-stem-name&gt;</span>

<span class="function-syntax">&lt;rulebook-stem-name&gt;</span>
<span class="plain-syntax">    {</span><span class="identifier-syntax">when</span><span class="plain-syntax"> ... </span><span class="identifier-syntax">begins</span><span class="plain-syntax">} |</span>
<span class="plain-syntax">    {</span><span class="identifier-syntax">when</span><span class="plain-syntax"> ... </span><span class="identifier-syntax">ends</span><span class="plain-syntax">} |</span>
<span class="plain-syntax">    ...</span>
</pre>
<p class="commentary firstcommentary"><a id="SP21_1" class="paragraph-anchor"></a><b>&#167;21.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Match the when scene begins exception</span><span class="named-paragraph-number">21.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">parsed_scene_stem_B</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RB_when_scene_begins</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">parsed_scene_stem_len</span><span class="plain-syntax"> = </span><span class="constant-syntax">2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    ==&gt; { -, - };</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="6-rlb.html#SP21">&#167;21</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP21_2" class="paragraph-anchor"></a><b>&#167;21.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Match the when scene ends exception</span><span class="named-paragraph-number">21.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">parsed_scene_stem_B</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RB_when_scene_ends</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">parsed_scene_stem_len</span><span class="plain-syntax"> = </span><span class="constant-syntax">2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    ==&gt; { -, - };</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="6-rlb.html#SP21">&#167;21</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP22" class="paragraph-anchor"></a><b>&#167;22. </b>In this function, <span class="extract"><span class="extract-syntax">SB</span></span> will be set for the hacky exceptional case where it's
known that the remaining text matches "when ... begins/ends", one of the scenes
rulebooks. This is all a bit inelegant, but we manage.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Rulebooks::rb_match_from_description</span><button class="popup" onclick="togglePopup('usagePopup18')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup18">Usage of <span class="code-font"><span class="function-syntax">Rulebooks::rb_match_from_description</span></span>:<br/><a href="6-rlb.html#SP20">&#167;20</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">SB</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">len</span><span class="plain-syntax">, </span><span class="reserved-syntax">rulebook_match</span><span class="plain-syntax"> *</span><span class="identifier-syntax">rm</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="6-rlb.html#SP22_1" class="named-paragraph-link"><span class="named-paragraph">Find the longest-named rulebook whose name appears at the front of W</span><span class="named-paragraph-number">22.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rm</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">matched_rulebook</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">rm</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">advance_words</span><span class="plain-syntax"> = </span><span class="identifier-syntax">rm</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">match_length</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rm</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">matched_rulebook</span><span class="plain-syntax"> == </span><span class="identifier-syntax">SB</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">rm</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">tail_words</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">rm</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">match_length</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>

<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="6-rlb.html#SP22_2" class="named-paragraph-link"><span class="named-paragraph">If the matched rulebook was derived from an action, match less text</span><span class="named-paragraph-number">22.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP22_1" class="paragraph-anchor"></a><b>&#167;22.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Find the longest-named rulebook whose name appears at the front of W</span><span class="named-paragraph-number">22.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER</span><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">, </span><span class="reserved-syntax">rulebook</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">B</span><span class="plain-syntax"> == </span><span class="identifier-syntax">SB</span><span class="plain-syntax">) { </span><span class="comment-syntax"> matches one of the scene begins/ends exceptions</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rm</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">match_length</span><span class="plain-syntax"> &lt; </span><span class="identifier-syntax">len</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">rm</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">match_length</span><span class="plain-syntax"> = </span><span class="identifier-syntax">len</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">rm</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">matched_rulebook</span><span class="plain-syntax"> = </span><span class="identifier-syntax">B</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> { </span><span class="comment-syntax"> any other rulebook</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Wordings::starts_with</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">primary_name</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rm</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">match_length</span><span class="plain-syntax"> &lt; </span><span class="identifier-syntax">Wordings::length</span><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">primary_name</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">rm</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">match_length</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wordings::length</span><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">primary_name</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">rm</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">matched_rulebook</span><span class="plain-syntax"> = </span><span class="identifier-syntax">B</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Wordings::starts_with</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">alternative_name</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rm</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">match_length</span><span class="plain-syntax"> &lt; </span><span class="identifier-syntax">Wordings::length</span><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">alternative_name</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">rm</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">match_length</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wordings::length</span><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">alternative_name</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">rm</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">matched_rulebook</span><span class="plain-syntax"> = </span><span class="identifier-syntax">B</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="6-rlb.html#SP22">&#167;22</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP22_2" class="paragraph-anchor"></a><b>&#167;22.2. </b><span class="extract"><span class="extract-syntax">action_stem_length</span></span> is zero except for rulebooks derived from actions, such
as "check taking". It is by definition the difference in length between the
rulebook name and the action name &mdash; here, therefore, it's 2 - 1 = 1.
</p>

<p class="commentary">If the entire text <span class="extract"><span class="extract-syntax">W</span></span> is the rulebook name &mdash; in this case, "check taking" &mdash;
we match that as normal. But if there is more text &mdash; say, "check taking an
open container" &mdash; then we retreat slightly and match only the prefix "check".
This ensures that something like "check taking or dropping something" is
initially, at least, put into the general check rulebook and not the specific
one for taking, where the "or dropping" part would never have effect.
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">If the matched rulebook was derived from an action, match less text</span><span class="named-paragraph-number">22.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rm</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">matched_rulebook</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">action_stem_length</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">w1a</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">) + </span><span class="identifier-syntax">rm</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">match_length</span><span class="plain-syntax"> - </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">w1a</span><span class="plain-syntax"> != </span><span class="identifier-syntax">Wordings::last_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">))</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">rm</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">match_length</span><span class="plain-syntax"> = </span><span class="identifier-syntax">rm</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">matched_rulebook</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">action_stem_length</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="6-rlb.html#SP22">&#167;22</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP23" class="paragraph-anchor"></a><b>&#167;23. Notable rulebooks.</b>A few rulebooks are special to Inform: we recognise them by their English names,
as used when they are created by the Standard Rules extension.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;notable-rulebooks&gt;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">action</span><span class="plain-syntax">-</span><span class="identifier-syntax">processing</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">after</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">before</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">carry</span><span class="plain-syntax"> </span><span class="identifier-syntax">out</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">check</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">instead</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">report</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">setting</span><span class="plain-syntax"> </span><span class="identifier-syntax">action</span><span class="plain-syntax"> </span><span class="identifier-syntax">variables</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">unsuccessful</span><span class="plain-syntax"> </span><span class="identifier-syntax">attempt</span><span class="plain-syntax"> </span><span class="identifier-syntax">by</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">when</span><span class="plain-syntax"> </span><span class="identifier-syntax">scene</span><span class="plain-syntax"> </span><span class="identifier-syntax">begins</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">when</span><span class="plain-syntax"> </span><span class="identifier-syntax">scene</span><span class="plain-syntax"> </span><span class="identifier-syntax">ends</span>
</pre>
<p class="commentary firstcommentary"><a id="SP24" class="paragraph-anchor"></a><b>&#167;24. </b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">RB_action_processing</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">RB_after</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">RB_before</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">RB_carry_out</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">RB_check</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">RB_instead</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">RB_report</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">RB_setting_action_variables</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">RB_unsuccessful_attempt</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">RB_when_scene_begins</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">RB_when_scene_ends</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
</pre>
<p class="commentary firstcommentary"><a id="SP25" class="paragraph-anchor"></a><b>&#167;25. </b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Rulebooks::detect_notable</span><button class="popup" onclick="togglePopup('usagePopup19')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup19">Usage of <span class="code-font"><span class="function-syntax">Rulebooks::detect_notable</span></span>:<br/><a href="6-rlb.html#SP2">&#167;2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="function-syntax">&lt;notable-rulebooks&gt;(B-&gt;</span><span class="element-syntax">primary_name</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="function-syntax">&lt;&lt;r&gt;&gt;</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">RB_action_processing</span><span class="plain-syntax"> = </span><span class="identifier-syntax">B</span><span class="plain-syntax">; </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax">: </span><span class="identifier-syntax">RB_after</span><span class="plain-syntax"> = </span><span class="identifier-syntax">B</span><span class="plain-syntax">; </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span><span class="plain-syntax">: </span><span class="identifier-syntax">RB_before</span><span class="plain-syntax"> = </span><span class="identifier-syntax">B</span><span class="plain-syntax">; </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="constant-syntax">3</span><span class="plain-syntax">: </span><span class="identifier-syntax">RB_carry_out</span><span class="plain-syntax"> = </span><span class="identifier-syntax">B</span><span class="plain-syntax">; </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="constant-syntax">4</span><span class="plain-syntax">: </span><span class="identifier-syntax">RB_check</span><span class="plain-syntax"> = </span><span class="identifier-syntax">B</span><span class="plain-syntax">; </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="constant-syntax">5</span><span class="plain-syntax">: </span><span class="identifier-syntax">RB_instead</span><span class="plain-syntax"> = </span><span class="identifier-syntax">B</span><span class="plain-syntax">; </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="constant-syntax">6</span><span class="plain-syntax">: </span><span class="identifier-syntax">RB_report</span><span class="plain-syntax"> = </span><span class="identifier-syntax">B</span><span class="plain-syntax">; </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="constant-syntax">7</span><span class="plain-syntax">: </span><span class="identifier-syntax">RB_setting_action_variables</span><span class="plain-syntax"> = </span><span class="identifier-syntax">B</span><span class="plain-syntax">; </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="constant-syntax">8</span><span class="plain-syntax">: </span><span class="identifier-syntax">RB_unsuccessful_attempt</span><span class="plain-syntax"> = </span><span class="identifier-syntax">B</span><span class="plain-syntax">; </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="constant-syntax">9</span><span class="plain-syntax">: </span><span class="identifier-syntax">RB_when_scene_begins</span><span class="plain-syntax"> = </span><span class="identifier-syntax">B</span><span class="plain-syntax">; </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="constant-syntax">10</span><span class="plain-syntax">: </span><span class="identifier-syntax">RB_when_scene_ends</span><span class="plain-syntax"> = </span><span class="identifier-syntax">B</span><span class="plain-syntax">; </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="6-bl.html">&#10094;</a></li><li class="progresschapter"><a href="P-wtmd.html">P</a></li><li class="progresschapter"><a href="1-am.html">1</a></li><li class="progresschapter"><a href="2-bv.html">2</a></li><li class="progresschapter"><a href="3-dlr.html">3</a></li><li class="progresschapter"><a href="4-nr.html">4</a></li><li class="progresschapter"><a href="5-id.html">5</a></li><li class="progresscurrentchapter">6</li><li class="progresssection"><a href="6-rls.html">rls</a></li><li class="progresssection"><a href="6-rb.html">rb</a></li><li class="progresssection"><a href="6-bl.html">bl</a></li><li class="progresscurrent">rlb</li><li class="progresssection"><a href="6-fao.html">fao</a></li><li class="progresssection"><a href="6-act.html">act</a></li><li class="progresssection"><a href="6-sv.html">sv</a></li><li class="progresschapter"><a href="7-tc.html">7</a></li><li class="progresschapter"><a href="8-kpr.html">8</a></li><li class="progressnext"><a href="6-fao.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

